﻿Imports WebSitePanel.SkinDesigner.Business.Css
Imports System.Drawing
Imports System.Reflection
Imports BoneSoft.CSS

Public Class CommandFactory
    Private files As Dictionary(Of CssFileType, CssFile)
    Friend Sub New(ByVal Files As Dictionary(Of CssFileType, CssFile))
        Me.files = Files
    End Sub
    Friend Function GetDocumentBackgroundImageCommand(ByVal ImagePath As String) As CommandBase
        Dim extension As String = Path.GetExtension(ImagePath)
        Dim repimg As New ReplaceImageCommand(Toolbox.TempPath & "TemporaryFiles\App_Themes\theme\images\docbackground" & extension, ImagePath)
        Dim bg As New CssCommand(files(CssFileType.SkinLayout), "BODY", "background-image", "url('file:///" & (Toolbox.TempPath & "TemporaryFiles\App_Themes\theme\images\docbackground" & extension).Replace("\", "/") & "')")
        Return New CompositeCommand(repimg, bg)
    End Function
    Friend Function GetDocumentBackgroundGradientCommand(ByVal GradientDefinition As GradientDefinition) As CommandBase
        Dim c1 As New CssCommand(files(CssFileType.SkinLayout), "#form1", "background-image", "url('file:///" & (Toolbox.TempPath & "TemporaryFiles\App_Themes\theme\images\formbackground.png").Replace("\", "/") & "')")
        Dim gradop As New GradientOperation(GradientDefinition.Color1, GradientDefinition.Color2)
        Dim c2 As New ImageOperationsCommand("formbackground.png", 1, GradientDefinition.Height, gradop)
        Dim c3 As New CssCommand(files(CssFileType.SkinLayout), "#form1", "background-repeat", "repeat-x")
        Return New CompositeCommand(c1, c2, c3)
    End Function
    Friend Function GetRemoveDocumentBackgroundImageCommand() As CommandBase
        Return New CssCommand(files(CssFileType.SkinLayout), "BODY", "background-image", "url('file:///" & (Toolbox.TempPath & "TemporaryFiles\App_Themes\theme\images\empty.gif").Replace("\", "/") & "')")
    End Function
    Friend Function GetDocumentBackgroundRepeatCommand(ByVal BackgroundRepeat As BackgroundRepeat) As CommandBase
        Dim value As String = String.Empty
        If BackgroundRepeat = Business.BackgroundRepeat.Repeat Then
            value = "repeat"
        ElseIf BackgroundRepeat = Business.BackgroundRepeat.RepeatX Then
            value = "repeat-x"
        ElseIf BackgroundRepeat = Business.BackgroundRepeat.RepeatY Then
            value = "repeat-y"
        Else
            value = "no-repeat"
        End If
        Return New CssCommand(files(CssFileType.SkinLayout), "BODY", "background-repeat", value)
    End Function
    Friend Function GetDocumentBackGroundCommand(ByVal Color As Color) As CommandBase
        Return New CssCommand(files(CssFileType.SkinLayout), "BODY", "background-color", Toolbox.GetHexColor(Color))
    End Function
    Friend Function GetHeaderColorCommand(ByVal Color As Color) As CommandBase
        Dim color2 As Color = files(CssFileType.SkinLayout).GetCssValue("#LoginSkinContent", "background-color").ToColor
        Return New ImageOperationsCommand("header_bkg.gif", 1, 20, New GradientOperation(Color, color2))
    End Function
    Friend Function GetTopMenuImageCommand(ByVal Color As Color, ByVal height As Integer, ByVal GlowMode As GlowMode) As CommandBase
        Return New ImageOperationsCommand("top_menu_bkg.gif", 1, height, GlowFactory.GetGlowOperation(Color, GlowMode))
    End Function
    Friend Function GetTopMenuHoverColorCommand(ByVal Color As Color, ByVal height As Integer, ByVal GlowMode As GlowMode) As CommandBase
        Return New ImageOperationsCommand("top_menu_hover_bkg.gif", 1, height, GlowFactory.GetGlowOperation(Color, GlowMode))
    End Function
    Friend Function GetTopMenuSplitterColorCommand(ByVal Color As Color)
        Dim c1 As New CssCommand(files(CssFileType.Menus), ".TopMenu ul.AspNet-Menu li span", "border-right", Toolbox.GetHexColor(Color), 2)
        Dim c2 As New CssCommand(files(CssFileType.Menus), ".TopMenu ul.AspNet-Menu li a", "border-right", Toolbox.GetHexColor(Color), 2)
        Return New CompositeCommand(c1, c2)
    End Function
    Friend Function GetTopMenuSplitterWidthCommand(ByVal Width As Integer)
        Dim c1 As New CssCommand(files(CssFileType.Menus), ".TopMenu ul.AspNet-Menu li span", "border-right", Width, 1)
        Dim c2 As New CssCommand(files(CssFileType.Menus), ".TopMenu ul.AspNet-Menu li a", "border-right", Width, 1)
        Return New CompositeCommand(c1, c2)
    End Function
    Friend Function GetTopMenuTopBorderColorCommand(ByVal Color As Color)
        Return New CssCommand(files(CssFileType.SkinLayout), "#TopMenu", "border-top", Toolbox.GetHexColor(Color), 2)
    End Function
    Friend Function GetTopMenuTopBorderWidthCommand(ByVal Width As Integer)
        Return New CssCommand(files(CssFileType.SkinLayout), "#TopMenu", "border-top", Width, 1)
    End Function
    Friend Function GetTopMenuBottomBorderColorCommand(ByVal Color As Color)
        Dim c1 As New CssCommand(files(CssFileType.SkinLayout), "#TopMenu", "border-bottom-color", Toolbox.GetHexColor(Color))
        Dim c2 As New CssCommand(files(CssFileType.SkinLayout), "#TopMenu", "border-bottom-style", "solid")
        Return New CompositeCommand(c1, c2)
    End Function
    Friend Function GetTopMenuBottomBorderWidthCommand(ByVal Width As Integer)
        Dim c1 As New CssCommand(files(CssFileType.SkinLayout), "#TopMenu", "border-bottom-width", Width & "px")
        Dim c2 As New CssCommand(files(CssFileType.SkinLayout), "#TopMenu", "border-bottom-style", "solid")
        Return New CompositeCommand(c1, c2)
    End Function
    Friend Function GetTopMenuHeightCommand(ByVal Height As Integer, ByVal Color As Color, ByVal HoverColor As Color, ByVal GlowMode As GlowMode)
        Dim c1 As New CssCommand(files(CssFileType.SkinLayout), "#TopMenu", "height", Height)
        Dim paddingtop As Integer = ((Height - 30) / 2) + 8
        Dim c2 As New CssCommand(files(CssFileType.Menus), ".TopMenu ul.AspNet-Menu li a", "padding", paddingtop)
        Dim c3 As New CssCommand(files(CssFileType.Menus), ".TopMenu ul.AspNet-Menu li span", "padding", paddingtop)
        Dim c4 As New CssCommand(files(CssFileType.Menus), ".TopMenu ul.AspNet-Menu li a", "padding", paddingtop, 2)
        Dim c5 As New CssCommand(files(CssFileType.Menus), ".TopMenu ul.AspNet-Menu li span", "padding", paddingtop, 2)
        Dim c6 As CommandBase = GetTopMenuImageCommand(Color, Height, GlowMode)
        Dim c7 As CommandBase = GetTopMenuHoverColorCommand(HoverColor, Height, GlowMode)
        Return New CompositeCommand(c1, c2, c3, c4, c5, c6, c7)
    End Function
    Friend Function GetTopMenuFontColorCommand(ByVal Color As Color) As CommandBase
        Dim c1 As New CssCommand(files(CssFileType.Menus), ".TopMenu ul.AspNet-Menu li span", "color", Toolbox.GetHexColor(Color))
        Dim c2 As New CssCommand(files(CssFileType.Menus), ".TopMenu ul.AspNet-Menu li a", "color", Toolbox.GetHexColor(Color))
        Return New CompositeCommand(c1, c2)
    End Function
    Friend Function GetTopMenuHoverFontColorCommand(ByVal Color As Color) As CommandBase
        Dim c1 As New CssCommand(files(CssFileType.Menus), ".TopMenu ul.AspNet-Menu li:hover a", "color", Toolbox.GetHexColor(Color))
        Dim c2 As New CssCommand(files(CssFileType.Menus), ".TopMenu ul.AspNet-Menu li span:hover", "color", Toolbox.GetHexColor(Color))
        Dim c3 As New CssCommand(files(CssFileType.Menus), ".TopMenu ul.AspNet-Menu li:hover span", "color", Toolbox.GetHexColor(Color))
        Dim c4 As New CssCommand(files(CssFileType.Menus), ".TopMenu ul.AspNet-Menu li.AspNet-Menu-Hover a", "color", Toolbox.GetHexColor(Color))
        Dim c5 As New CssCommand(files(CssFileType.Menus), ".TopMenu ul.AspNet-Menu li.AspNet-Menu-Hover span", "color", Toolbox.GetHexColor(Color))
        Dim c6 As New CssCommand(files(CssFileType.Menus), ".TopMenu ul.AspNet-Menu li.AspNet-Menu-Hover a:hover", "color", Toolbox.GetHexColor(Color))
        Dim c7 As New CssCommand(files(CssFileType.Menus), ".TopMenu ul.AspNet-Menu li.AspNet-Menu-Hover span:hover", "color", Toolbox.GetHexColor(Color))
        Return New CompositeCommand(c1, c2, c3, c4, c5, c6, c7)
    End Function
    Friend Function GetContainerColorCommand(ByVal Color As Color, ByVal BackgroundColor As Color, ByVal BorderColor As Color, ByVal RoundedCorners As Boolean, ByVal GlowMode As GlowMode) As CommandBase
        Dim borderhex As String = Toolbox.GetHexColor(BorderColor)
        Dim leftoperations As New List(Of ImageOperationBase)
        Dim topoperations As New List(Of ImageOperationBase)
        Dim rightoperations As New List(Of ImageOperationBase)

        Dim glow As ImageOperationBase = GlowFactory.GetGlowOperation(Color, GlowMode)
        Dim leftborder As New BorderOperation(1, BorderColor, BorderType.Left)
        Dim topborder As New BorderOperation(1, BorderColor, BorderType.Top)
        Dim rightborder As New BorderOperation(1, BorderColor, BorderType.Right)
        Dim bottomborder As New BorderOperation(1, BorderColor, BorderType.Bottom)
        Dim rect As New AddRectangleOperation(BackgroundColor, New Rectangle(0, 0, 6, 33))

        leftoperations.AddRange({glow, rect, leftborder, bottomborder})
        topoperations.AddRange({glow, rect, topborder, bottomborder})
        rightoperations.AddRange({glow, rect, rightborder, bottomborder})
        If RoundedCorners Then
            Dim leftround As New RoundedCornerOperation(12, BackgroundColor, BorderColor, CornerType.LeftTop)
            Dim rightround As New RoundedCornerOperation(12, BackgroundColor, BorderColor, CornerType.RightTop)
            leftoperations.Add(leftround)
            rightoperations.Add(rightround)
        Else
            leftoperations.Add(topborder)
            rightoperations.Add(topborder)
        End If

        Dim c1 As New ImageOperationsCommand("module_header_left.gif", 6, 27, leftoperations.ToArray)
        Dim c2 As New ImageOperationsCommand("module_header_bkg.gif", 1, 27, topoperations.ToArray)
        Dim c3 As New ImageOperationsCommand("module_header_right.gif", 6, 27, rightoperations.ToArray)

        Dim c4 As New CssCommand(files(CssFileType.Containers), ".BrowseContainer .Content", "border", borderhex, 2)
        Dim c5 As New CssCommand(files(CssFileType.Containers), ".EditContainer .Content", "border", borderhex, 2)
        Dim c6 As New CssCommand(files(CssFileType.Containers), ".LoginContainer .Content", "border", borderhex, 2)
        Dim c7 As New CssCommand(files(CssFileType.Containers), ".PopUpContainer .Content", "border", borderhex)
        Return New CompositeCommand(c1, c2, c3, c4, c5, c6, c7)
    End Function
    Friend Function GetPageColorCommand(ByVal Color As Color) As CommandBase
        Dim cstring As String = Toolbox.GetHexColor(Color)
        Dim commands As New List(Of CommandBase)
        commands.Add(New CssCommand(files(CssFileType.Skin), ".FormButtonsBar", "background", cstring))
        commands.Add(New CssCommand(files(CssFileType.Containers), ".Content", "background-color", cstring))
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Content", "background", cstring))
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#SkinContent", "background-color", cstring))
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#LoginSkinContent", "background-color", cstring))
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#HeaderLogin", "background", cstring))
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Header", "background", cstring))
        commands.Add(New CssCommand(files(CssFileType.Containers), ".LoginContainer .Content", "background-color", cstring))
        commands.Add(New CssCommand(files(CssFileType.Containers), ".BrowseContainer .Content", "background-color", cstring))
        commands.Add(New CssCommand(files(CssFileType.Grids), ".NormalGridView .AspNet-GridView table tbody tr td", "background", cstring))
        commands.Add(New CssCommand(files(CssFileType.Grids), ".NormalGridView .AspNet-GridView table thead tr th", "background", cstring))

        Dim gradop As New GradientOperation(ControlPaint.Light(Color, 1.0F), Color)
        commands.Add(New ImageOperationsCommand("content_bkg.gif", 1, 23, gradop))
        commands.Add(New ImageOperationsCommand("grid_header.gif", 1, 22, gradop))
        Return New CompositeCommand(commands)
    End Function
    Friend Function GetPagePaddingCommand(ByVal Padding As Integer) As CommandBase
        Dim commands As New List(Of CommandBase)
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Header", "margin", Padding, 1))
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Header", "margin", Padding, 3))
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#HeaderLogin", "margin", Padding, 1))
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#HeaderLogin", "margin", Padding, 3))
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Content-Login", "margin-left", Padding & "px"))
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Content-Login", "margin-right", Padding & "px"))
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#TopMenu", "margin", Padding, 1))
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#TopMenu", "margin", Padding, 3))
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Top", "margin", Padding, 1))
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Top", "margin", Padding, 3))
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Left", "margin", Padding, 1))
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Left", "margin", Padding, 3))
        Dim currentpaddingterm As Term = files(CssFileType.SkinLayout).GetCssValue("#Left", "margin", 3)
        Dim currentpadding As Integer = 0
        If currentpaddingterm IsNot Nothing Then
            currentpadding = currentpaddingterm.Value.Replace("px", "")
        End If
        Dim width As Integer = files(CssFileType.SkinLayout).GetCssValue("#Content", "width").Value
        width = width + currentpadding - Padding
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Content", "width", width))
        Dim skinwidth As Integer = files(CssFileType.SkinLayout).GetCssValue("#SkinOutline", "width").Value
        skinwidth = skinwidth - currentpadding + Padding
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#SkinOutline", "width", skinwidth))
        Return New CompositeCommand(commands)
    End Function
    Friend Function GetPageOffsetCommand(ByVal Offset As Integer) As CommandBase
        Dim c1 As New CssCommand(files(CssFileType.SkinLayout), "#SkinOutline", "margin-top", Offset & "px")
        Dim c2 As New CssCommand(files(CssFileType.SkinLayout), "#LoginSkinOutline", "margin-top", Offset & "px")
        Return New CompositeCommand(c1, c2)
    End Function
    Friend Function GetPageBorderColorCommand(ByVal Color As Color) As CommandBase
        Dim c1 As New CssCommand(files(CssFileType.SkinLayout), "#LoginSkinContent", "border-color", Toolbox.GetHexColor(Color))
        Dim c2 As New CssCommand(files(CssFileType.SkinLayout), "#SkinContent", "border-color", Toolbox.GetHexColor(Color))
        Return New CompositeCommand(c1, c2)
    End Function
    Friend Function GetPageBorderWidthCommand(ByVal Width As Integer) As CommandBase
        Dim commands As New List(Of CommandBase)
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#LoginSkinContent", "border-width", Width & "px"))
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#SkinContent", "border-width", Width & "px"))
        Dim currentwidthterm As Term = files(CssFileType.SkinLayout).GetCssValue("#SkinContent", "border-width")
        Dim currentwidth As Integer
        If currentwidthterm Is Nothing Then
            currentwidth = 0
        Else
            currentwidth = currentwidthterm.Value.Replace("px", "")
        End If
        Dim pagewidth As Integer = files(CssFileType.SkinLayout).GetCssValue("#Content", "width").Value
        pagewidth = pagewidth + ((currentwidth - Width) * 2)
        'commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Content", "width", pagewidth))
        Dim skinwidth As Integer = files(CssFileType.SkinLayout).GetCssValue("#SkinOutline", "width").Value
        skinwidth = skinwidth - ((currentwidth - Width) * 2)
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#SkinOutline", "width", skinwidth))
        Return New CompositeCommand(commands)
    End Function
    Friend Function GetPageBorderStyleCommand(ByVal Style As String)
        Dim c1 As New CssCommand(files(CssFileType.SkinLayout), "#LoginSkinContent", "border-style", Style)
        Dim c2 As New CssCommand(files(CssFileType.SkinLayout), "#SkinContent", "border-style", Style)
        Dim currentwidthterm As Term = files(CssFileType.SkinLayout).GetCssValue("#SkinContent", "border-width")
        Dim currentwidth As Integer
        If currentwidthterm Is Nothing Then
            currentwidth = 0
        Else
            currentwidth = currentwidthterm.Value.Replace("px", "")
        End If
        Dim c3 As CommandBase = GetPageBorderWidthCommand(currentwidth)
        Return New CompositeCommand(c1, c2, c3)
    End Function
    Friend Function GetPageLinkColorCommand(ByVal Color As Color) As CommandBase
        Return New CssCommand(files(CssFileType.Skin), "A", "color", Toolbox.GetHexColor(Color))
    End Function
    Friend Function GetFooterFontCommand(ByVal Size As Integer, ByVal Family As String, ByVal Bold As Boolean, ByVal Italic As Boolean, ByVal Underline As Boolean, ByVal Color As Color) As CommandBase
        Dim c1 As New CssCommand(files(CssFileType.SkinLayout), "#Footer", "font-size", Size)
        Dim c2 As New CssCommand(files(CssFileType.SkinLayout), "#Footer", "font-family", Family)
        Dim boldstring As String = IIf(Bold, "bold", "normal")
        Dim italicstring As String = IIf(Italic, "italic", "normal")
        Dim decoration As String = IIf(Underline, "underline", "none")

        Dim c3 As New CssCommand(files(CssFileType.SkinLayout), "#Footer", "font-weight", IIf(Bold, "bold", "normal"))
        Dim c4 As New CssCommand(files(CssFileType.SkinLayout), "#Footer", "font-style", IIf(Italic, "italic", "normal"))
        Dim c5 As New CssCommand(files(CssFileType.SkinLayout), "#Footer", "text-decoration", IIf(Underline, "underline", "none"))
        Dim c6 As New CssCommand(files(CssFileType.SkinLayout), "#Footer", "color", Toolbox.GetHexColor(Color))
        Return New CompositeCommand(c1, c2, c3, c4, c5, c6)
    End Function
    Friend Function GetAccountFontCommand(ByVal Size As Integer, ByVal Family As String, ByVal Bold As Boolean, ByVal Italic As Boolean, ByVal Underline As Boolean, ByVal Color As Color) As CommandBase
        Dim c1 As New CssCommand(files(CssFileType.SkinLayout), "#Header .Account", "font-size", Size)
        Dim c2 As New CssCommand(files(CssFileType.SkinLayout), "#Header .Account", "font-family", Family)
        Dim boldstring As String = IIf(Bold, "bold", "normal")
        Dim italicstring As String = IIf(Italic, "italic", "normal")
        Dim decoration As String = IIf(Underline, "underline", "none")

        Dim c3 As New CssCommand(files(CssFileType.SkinLayout), "#Header .Account", "font-weight", IIf(Bold, "bold", "normal"))
        Dim c4 As New CssCommand(files(CssFileType.SkinLayout), "#Header .Account", "font-style", IIf(Italic, "italic", "normal"))
        Dim c5 As New CssCommand(files(CssFileType.SkinLayout), "#Header .Account", "text-decoration", IIf(Underline, "underline", "none"))
        Dim c6 As New CssCommand(files(CssFileType.SkinLayout), "#Header .Account", "color", Toolbox.GetHexColor(Color))
        Return New CompositeCommand(c1, c2, c3, c4, c5, c6)
    End Function
    Friend Function GetFooterLinkColorCommand(ByVal Color As Color)
        Return New CssCommand(files(CssFileType.SkinLayout), "#Footer A", "color", Toolbox.GetHexColor(Color))
    End Function
    Friend Function GetBreadCrumbBackGroundColorCommand(ByVal color As Color)
        Return New CssCommand(files(CssFileType.SkinLayout), "#Breadcrumb", "background", Toolbox.GetHexColor(color))
    End Function
    Friend Function GetBreadCrumbFontCommand(ByVal Size As Integer, ByVal Family As String, ByVal Bold As Boolean, ByVal Italic As Boolean, ByVal Underline As Boolean, ByVal Color As Color) As CommandBase
        Dim bcselector As String = "#Breadcrumb .CurrentNode span.Huge"
        Dim c1 As New CssCommand(files(CssFileType.SkinLayout), bcselector, "font-size", Size)
        Dim c2 As New CssCommand(files(CssFileType.SkinLayout), bcselector, "font-family", Family)
        Dim boldstring As String = IIf(Bold, "bold", "normal")
        Dim italicstring As String = IIf(Italic, "italic", "normal")
        Dim decoration As String = IIf(Underline, "underline", "none")

        Dim c3 As New CssCommand(files(CssFileType.SkinLayout), bcselector, "font-weight", IIf(Bold, "bold", "normal"))
        Dim c4 As New CssCommand(files(CssFileType.SkinLayout), bcselector, "font-style", IIf(Italic, "italic", "normal"))
        Dim c5 As New CssCommand(files(CssFileType.SkinLayout), bcselector, "text-decoration", IIf(Underline, "underline", "none"))
        Dim c6 As New CssCommand(files(CssFileType.SkinLayout), bcselector, "color", Toolbox.GetHexColor(Color))
        Return New CompositeCommand(c1, c2, c3, c4, c5, c6)
    End Function
    Friend Function GetBreadCrumbLinkFontCommand(ByVal Size As Integer, ByVal Family As String, ByVal Bold As Boolean, ByVal Italic As Boolean, ByVal Underline As Boolean, ByVal Color As Color) As CommandBase
        Dim bcselector As String = "#Breadcrumb .Path A"
        Dim t As Term = files(CssFileType.SkinLayout).GetCssValue(bcselector, "font-size")
        Dim sizestring As String = Size
        If t Is Nothing Then
            sizestring &= "px"
        End If
        Dim c1 As New CssCommand(files(CssFileType.SkinLayout), bcselector, "font-size", sizestring)
        Dim c2 As New CssCommand(files(CssFileType.SkinLayout), bcselector, "font-family", Family)
        Dim boldstring As String = IIf(Bold, "bold", "normal")
        Dim italicstring As String = IIf(Italic, "italic", "normal")
        Dim decoration As String = IIf(Underline, "underline", "none")

        Dim c3 As New CssCommand(files(CssFileType.SkinLayout), bcselector, "font-weight", IIf(Bold, "bold", "normal"))
        Dim c4 As New CssCommand(files(CssFileType.SkinLayout), bcselector, "font-style", IIf(Italic, "italic", "normal"))
        Dim c5 As New CssCommand(files(CssFileType.SkinLayout), bcselector, "text-decoration", IIf(Underline, "underline", "none"))
        Dim c6 As New CssCommand(files(CssFileType.SkinLayout), bcselector, "color", Toolbox.GetHexColor(Color))
        Return New CompositeCommand(c1, c2, c3, c4, c5, c6)
    End Function
    Friend Function GetBreadCrumbBorderColorCommand(ByVal Color As Color) As CommandBase
        Return New CssCommand(files(CssFileType.SkinLayout), "#Breadcrumb", "border-bottom", Toolbox.GetHexColor(Color), 2)
    End Function
    Friend Function GetBreadCrumbBorderWidthCommand(ByVal Width As Integer) As CommandBase
        Return New CssCommand(files(CssFileType.SkinLayout), "#Breadcrumb", "border-bottom", Width, 1)
    End Function
    Friend Function GetBreadCrumbBorderStyleCommand(ByVal Style As String)
        Return New CssCommand(files(CssFileType.SkinLayout), "#Breadcrumb", "border-bottom", Style)
    End Function
    Friend Function GetSecondaryMenuColorCommand(ByVal ContentColor As Color, ByVal TitleColor As Color, ByVal GradientColor As Color, ByVal BorderColor As Color)
        Dim cstring As String = Toolbox.GetHexColor(ContentColor)
        Dim c1 As New CssCommand(files(CssFileType.SkinLayout), "#Left .Menu", "background-color", cstring)
        Dim c2 As New CssCommand(files(CssFileType.Menus), ".LeftMenu ul", "background-color", cstring)
        Dim c3 As New CssCommand(files(CssFileType.SkinLayout), "#Left .Menu", "border", Toolbox.GetHexColor(BorderColor), 2)
        Dim c4 As New LeftMenuHeaderImageCommand(ContentColor, TitleColor, GradientColor, BorderColor)
        Return New CompositeCommand(c1, c2, c3, c4)
    End Function
    Friend Function GetSecondaryMenuPositionCommand(ByVal Position As Position) As CommandBase
        Dim commands As New List(Of CommandBase)
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Left", "float", Position.ToString))
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Center", "float", Position.ToString))
        Select Case Position
            Case Business.Position.Left
                commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Breadcrumb", "padding-left", 10))
                commands.Add(New CssCommand(files(CssFileType.Menus), ".LeftMenu ul.AspNet-Menu ul", "left", 190))
                commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Center", "padding", 0, 1))
                commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Center", "padding", 10, 3))
            Case Business.Position.Right
                commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Breadcrumb", "padding-left", 260))
                commands.Add(New CssCommand(files(CssFileType.Menus), ".LeftMenu ul.AspNet-Menu ul", "left", -190))
                commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Center", "padding", 10, 1))
                commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Center", "padding", 0, 3))
        End Select
        Return New CompositeCommand(commands)
    End Function
    Friend Function GetSecondaryMenuPaddingCommand(ByVal Left As Integer, ByVal Top As Integer, ByVal Right As Integer) As CommandBase
        Dim commands As New List(Of CommandBase)
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Left", "top", (Top - 15) & "px"))
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Left", "margin", Left, 3))
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Center", "padding-left", Right))
        commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Content", "width", 789 - Left))
        If Right + Left >= 20 Then
            commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Right", "padding-left", 9))
        Else
            commands.Add(New CssCommand(files(CssFileType.SkinLayout), "#Right", "padding-left", 10))
        End If
        Return New CompositeCommand(commands)
    End Function
    Friend Function GetSecondaryMenuHoverCommand(ByVal Color As Color, ByVal BackgroundColor As Color, ByVal BorderColor As Color, ByVal RoundedCorners As Boolean, ByVal GlowMode As GlowMode) As CommandBase
        Dim borderhex As String = Toolbox.GetHexColor(BorderColor)
        Dim operations As New List(Of ImageOperationBase)

        Dim glow As ImageOperationBase = GlowFactory.GetGlowOperation(Color, GlowMode)
        Dim leftborder As New BorderOperation(1, BorderColor, BorderType.Left)
        Dim topborder As New BorderOperation(1, BorderColor, BorderType.Top)
        Dim rightborder As New BorderOperation(1, BorderColor, BorderType.Right)
        Dim bottomborder As New BorderOperation(1, BorderColor, BorderType.Bottom)

        operations.AddRange({glow, leftborder, bottomborder, topborder, rightborder})
        If RoundedCorners Then
            operations.Add(New RoundedCornerOperation(6, BackgroundColor, BorderColor, CornerType.LeftTop))
            operations.Add(New RoundedCornerOperation(6, BackgroundColor, BorderColor, CornerType.RightTop))
            operations.Add(New RoundedCornerOperation(6, BackgroundColor, BorderColor, CornerType.LeftBottom))
            operations.Add(New RoundedCornerOperation(6, BackgroundColor, BorderColor, CornerType.RightBottom))
        End If

        Return New ImageOperationsCommand("left_menu_hover_bkg.gif", 190, 25, operations.ToArray)
    End Function
    Friend Function GetSecondaryMenuTitleFontCommand(ByVal Size As Integer, ByVal Family As String, ByVal Bold As Boolean, ByVal Italic As Boolean, ByVal Underline As Boolean, ByVal Color As Color) As CommandBase
        Dim c1 As New CssCommand(files(CssFileType.SkinLayout), "#Left .MenuHeader", "font-size", Size)
        Dim c2 As New CssCommand(files(CssFileType.SkinLayout), "#Left .MenuHeader", "font-family", Family)
        Dim boldstring As String = IIf(Bold, "bold", "normal")
        Dim italicstring As String = IIf(Italic, "italic", "normal")
        Dim decoration As String = IIf(Underline, "underline", "none")

        Dim c3 As New CssCommand(files(CssFileType.SkinLayout), "#Left .MenuHeader", "font-weight", IIf(Bold, "bold", "normal"))
        Dim c4 As New CssCommand(files(CssFileType.SkinLayout), "#Left .MenuHeader", "font-style", IIf(Italic, "italic", "normal"))
        Dim c5 As New CssCommand(files(CssFileType.SkinLayout), "#Left .MenuHeader", "text-decoration", IIf(Underline, "underline", "none"))
        Dim c6 As New CssCommand(files(CssFileType.SkinLayout), "#Left .MenuHeader", "color", Toolbox.GetHexColor(Color))
        Return New CompositeCommand(c1, c2, c3, c4, c5, c6)
    End Function
    Friend Function GetSecondaryMenuLinksFontCommand(ByVal Size As Integer, ByVal Family As String, ByVal Bold As Boolean, ByVal Italic As Boolean, ByVal Underline As Boolean, ByVal Color As Color) As CommandBase
        Dim commands As New List(Of CommandBase)
        commands.Add(New CssCommand(files(CssFileType.Menus), ".LeftMenu ul.AspNet-Menu li span", "font-size", Size))
        commands.Add(New CssCommand(files(CssFileType.Menus), ".LeftMenu ul.AspNet-Menu li span", "font-family", Family))
        commands.Add(New CssCommand(files(CssFileType.Menus), ".LeftMenu ul.AspNet-Menu li span", "font-weight", IIf(Bold, "bold", "normal")))
        commands.Add(New CssCommand(files(CssFileType.Menus), ".LeftMenu ul.AspNet-Menu li span", "font-style", IIf(Italic, "italic", "normal")))
        commands.Add(New CssCommand(files(CssFileType.Menus), ".LeftMenu ul.AspNet-Menu li span", "text-decoration", IIf(Underline, "underline", "none")))
        commands.Add(New CssCommand(files(CssFileType.Menus), ".LeftMenu ul.AspNet-Menu li span", "color", Toolbox.GetHexColor(Color)))
        commands.Add(New CssCommand(files(CssFileType.Menus), ".LeftMenu ul.AspNet-Menu li a", "font-size", Size))
        commands.Add(New CssCommand(files(CssFileType.Menus), ".LeftMenu ul.AspNet-Menu li a", "font-family", Family))
        commands.Add(New CssCommand(files(CssFileType.Menus), ".LeftMenu ul.AspNet-Menu li a", "font-weight", IIf(Bold, "bold", "normal")))
        commands.Add(New CssCommand(files(CssFileType.Menus), ".LeftMenu ul.AspNet-Menu li a", "font-style", IIf(Italic, "italic", "normal")))
        commands.Add(New CssCommand(files(CssFileType.Menus), ".LeftMenu ul.AspNet-Menu li a", "text-decoration", IIf(Underline, "underline", "none")))
        commands.Add(New CssCommand(files(CssFileType.Menus), ".LeftMenu ul.AspNet-Menu li a", "color", Toolbox.GetHexColor(Color)))
        Return New CompositeCommand(commands)
    End Function
    Friend Function GetRightPanelTitleFontCommand(ByVal Size As Integer, ByVal Family As String, ByVal Bold As Boolean, ByVal Italic As Boolean, ByVal Underline As Boolean, ByVal Color As Color) As CommandBase
        Dim c1 As New CssCommand(files(CssFileType.Skin), ".RightBlockTitle", "font-size", Size)
        Dim c2 As New CssCommand(files(CssFileType.Skin), ".RightBlockTitle", "font-family", Family)
        Dim boldstring As String = IIf(Bold, "bold", "normal")
        Dim italicstring As String = IIf(Italic, "italic", "normal")
        Dim decoration As String = IIf(Underline, "underline", "none")

        Dim c3 As New CssCommand(files(CssFileType.Skin), ".RightBlockTitle", "font-weight", IIf(Bold, "bold", "normal"))
        Dim c4 As New CssCommand(files(CssFileType.Skin), ".RightBlockTitle", "font-style", IIf(Italic, "italic", "normal"))
        Dim c5 As New CssCommand(files(CssFileType.Skin), ".RightBlockTitle", "text-decoration", IIf(Underline, "underline", "none"))
        Dim c6 As New CssCommand(files(CssFileType.Skin), ".RightBlockTitle", "color", Toolbox.GetHexColor(Color))
        Return New CompositeCommand(c1, c2, c3, c4, c5, c6)
    End Function
    Friend Function GetRightPanelPositionCommand(ByVal Position As Integer) As CommandBase
        Return New CssCommand(files(CssFileType.SkinLayout), "#Right", "top", (Position - 65) & "px")
    End Function
End Class